<template>
    <Teleport to=".hearder-show">
        <div class="details-box">
商品详情
        </div>
    </Teleport>
    
</template>
<script setup lang="ts">
 import {Teleport} from 'vue'
 import { useRoute, type RouteLocationNormalizedLoaded } from 'vue-router'
import { onMounted } from 'vue'

const $route: RouteLocationNormalizedLoaded = useRoute()
const setLocalStorage = (text: string): void => {
    const historyList: string[] = JSON.parse(window.localStorage.getItem('history') as string) || []
    
  const res: boolean = historyList.indexOf(text) !== -1

if (res) return

 historyList.push(text)

window.localStorage.setItem('history', JSON.stringify(historyList))


}
onMounted(() => {
  const searchText = $route.query.search
  searchText && setLocalStorage(searchText as string)
})

 </script>
<style lang="scss" scoped></style>